/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.model.events;

/**
 * This is a subclass of XREEvent that represents the "onHTMLLinkClicked" and "onScroll" event. It defines some
 * properties specific to this event. Note that values of all custom properties are actually stored in the
 * XREEvent#params map.
 * <p>
 * <b>Thread safety:</b> This class is mutable and not thread safe.
 * <p>
 * AndroidAssembly3 this class was added in Android Assembly 3
 *
 * @author TCSASSEMBLER
 * @version 1.0
 */
public class XREHTMLEvent extends XREResourceEvent {

    /**
     * <p>
     * Represents the name of the "on HTML link clicked" event.
     * </p>
     * <p>
     * This is a string constant used by the user when setting the name of the event.
     * </p>
     */
    public static final String ON_HTML_LINK_CLICKED_EVENT_NAME = "onHTMLLinkClicked";
    /**
     * <p>
     * Represents the name of the "on HTML link clicked" event.
     * </p>
     * <p>
     * This is a string constant used by the user when setting the name of the event.
     * </p>
     */
    public static final String ON_SCROLL_EVENT_NAME = "onScroll";

    /**
     * <p>
     * Represents the name used to retrieve the value parameter.
     * </p>
     */
    private static final String VALUE = "value";

    /**
     * <p>
     * Creates new instance of {@link XREHTMLEvent} class.
     * </p>
     */
    public XREHTMLEvent() {
        // empty constructor
    }

    /**
     * <p>
     * Retrieves the string identifying which link was clicked.
     * </p>
     *
     * @return the string identifying which link was clicked
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public String getValue() {
        return getTypedParam(VALUE, String.class);
    }

    /**
     * <p>
     * Sets the string identifying which link was clicked. Each HTML anchor &lt;a&gt; tag will have an HREF property in
     * the following format "event:&lt;value&gt;". The argument is the text to the right of the ":" separator in the
     * HREF property.
     * </p>
     *
     * @param value the string identifying which link was clicked
     * @throws IllegalStateException if params is null
     */
    public void setValue(String value) {
        setParam(VALUE, value);
    }
}
